package com.zuihai.app.mvp.ui.activity.home;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.zuihai.app.mvp.constant.DetailConstant;
import com.zuihai.app.mvp.model.entity.HomeItem;
import com.zuihai.app.mvp.ui.activity.detail.DetailContainerActivity;

import java.util.Calendar;

/**
 * Created by Zc on 2017/5/3.
 * 首页-图片
 */

public class HomePictureFragment extends HomeRecyclerFragment {
    private String type="";

    public static HomePictureFragment newInstance(String type) {
        Bundle args = new Bundle();
        args.putString("type", type);
        HomePictureFragment fragment = new HomePictureFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void initData() {
        super.initData();
        type=getArguments().getString("type");
    }

    @Override
    protected void requestData(boolean isRefresh) {
        mPresenter.requestPicture(isRefresh,type);
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            HomeItem item = (HomeItem) adapter.getItem(position);
            DetailContainerActivity.launchActivity(getContext(), DetailConstant.PICTURE_TYPE, item.id);
        }
    }
}
